set(LIB_NAME sgm)
find_package(CUDA REQUIRED)
find_package(OpenCV  REQUIRED)
set(CUDA_ARCH "-gencode;arch=compute_72,code=sm_72" )
option(SGM_SHARED "build sgm shared lib" ON)

configure_file( ${PROJECT_SOURCE_DIR}/include/stereo_vision/sgm_config.h.in
                ${PROJECT_SOURCE_DIR}/include/stereo_vision/sgm_config.h)

message(STATUS "CUDA_ARCH: \"${CUDA_ARCH}\"")

SET(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} ${CUDA_ARCH}")

file(GLOB STEREOSRCS "*.cu" "*.cpp")

include_directories(
    ${PROJECT_SOURCE_DIR}/include
    ${Opencv_INCLUDE_DIRS}
)
if(${SGM_SHARED})
    CUDA_ADD_LIBRARY(${LIB_NAME} ${STEREOSRCS}  SHARED)
    target_link_libraries(${LIB_NAME} ${CUDA_LIBRARIES}  ${YAML_CPP_LIBRARIES}  ${OpenCV_LIBRARIES})

else()
    CUDA_ADD_LIBRARY(${LIB_NAME} ${STEREOSRCS} STATIC)
endif()
set(CMAKE_STAGING_PREFIX /opt/adc)
install(TARGETS sgm
        ARCHIVE DESTINATION ${CMAKE_STAGING_PREFIX}/lib
        LIBRARY DESTINATION ${CMAKE_STAGING_PREFIX}/lib
       # RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
      )
